import java.io.IOException;
import java.io.InputStream;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class UdpDictSrever extends UdpEchoServer {////翻译类型的服务器
    private Map<String,String> map=new HashMap<>();//使用hashmap键值对来翻译
    public UdpDictSrever(int port) throws SocketException {//在构造方法里初始化字典
        super(port);//帮助父类构造
        map.put("cat","猫");
        map.put("fack","问好");
        map.put("hello","你好");
        map.put("zcw","微");
        map.put("yl","叶");
    }
    @Override
    public String process(String request){//重写响应方法
        return map.getOrDefault(request,"单词未找到");
    }

    public static void main(String[] args) throws IOException {
        UdpDictSrever udpDictSrever=new UdpDictSrever(4090);
        udpDictSrever.stack();


    }

}
